package com.sshtools.cmd.action.impl;

import com.sshtools.cmd.action.ServerCmdTask;
import com.sshtools.view.model.ServerModel;

/**
 * 服务器重启任务
 *
 */
public class RestartTask extends ServerCmdTask {

	public RestartTask(ServerModel server) {
		super(server);
	}

	@Override
	protected String[] getCommand() {
		// 判断重启命令是否为空
		String restartCommand = server.getRestartCommand();
		if (restartCommand != null && restartCommand.length() > 0) {
			return new String[] { restartCommand }; // 直接走重启指令
		}

		// 改用关闭与启动指令代替
		return new String[] { server.getStopCommand(), server.getStartCommand() };
	}

}